package com.xquant.trade.trade.service;

import com.xquant.trade.trade.mapper.TequityStructureMapper;
import com.xquant.trade.utils.CacheUtil;
import com.xquant.trade.trade.mapper.TradeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Auther: B946
 * @Date: 23/12/2019 10:17
 * @Description:
 */
@Service
@Transactional
public class OptionRemindService {

    @Autowired
    TradeMapper tradeMapper;
    @Autowired
    TequityStructureMapper tequityStructureMapper;

    ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
    //时间间隔(一天)
    private static final long PERIOD_DAY = 24 * 60 * 60 * 1000;


    /**
     * 项目启动时，初始化到缓存
     */
    @PostConstruct
    public void init() {

        Runnable runnable = new Runnable() {
            public void run() {
                try {
                    Thread.sleep(50000 * 1000);
                    CacheUtil.getInstance().removeAllCacheData();
           
                    Map map = new HashMap();


                } catch (InterruptedException e) {

                }
            }
        };
        // 第二个参数为首次执行的延时时间，第三个参数为定时执行的间隔时间
        scheduledExecutorService.scheduleAtFixedRate(runnable, 0, PERIOD_DAY, TimeUnit.MILLISECONDS);

    }


}
